﻿<%@ WebHandler Language="C#" Class="control" %>

using System;
using System.Web;
using System.Collections.Generic;

public class control : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        string weiboId = context.Request.QueryString["weiboId"];
        int status = Convert.ToInt32(context.Request.QueryString["status"]);
        DealWeiboEnum type = (DealWeiboEnum)Convert.ToInt32(context.Request.QueryString["type"]);
        DealedWeiboProxy proxy = new DealedWeiboProxy();
        switch (type)
        {
            case DealWeiboEnum.UPDATE:
                DealedWeiboData data = proxy.Update(weiboId, status);
                 context.Response.Write(Message.CreateMessage(true, data.toJson()));
                break;
            case DealWeiboEnum.SELECT_LIST:
                context.Response.Write(Message.CreateMessage(true, SelectList()));
                break;
        }
    }

    private string SelectList()
    {
        List<DealedWeiboData> list = new DealedWeiboProxy().SelectList();
        string result = "";
        for (int i = 0; i < list.Count; i++)
        {
            result += list[i].toJson();
            if (i < list.Count - 1)
                result += ",";
        }
        return "[" + result + "]";
    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}